Skip to content

feat(workspace): add rootResolution setting for multi-root workspaces#538

Open
simurg79 wants to merge 2 commits into
Zoo-Code-Org:mainfrom
simurg79:feat/workspace-root-resolution
Open

feat(workspace): add rootResolution setting for multi-root workspaces#538
simurg79 wants to merge 2 commits into
Zoo-Code-Org:mainfrom
simurg79:feat/workspace-root-resolution

Conversation

@simurg79

@simurg79 simurg79 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Ports the workspace root resolution feature from simurg79/Roo-Code (commit d89c1ff) into Zoo-Code.

Introduces a new zoo-code.workspace.rootResolution VS Code setting that controls how Zoo resolves the "project root" in a multi-root workspace (used to locate .roomodes, .roo/mcp.json, .roo/rules/, and other project-scoped configuration):

Value Behavior
activeEditor (default) Prefer the workspace folder containing the active editor; fall back to workspaceFolders[0]. Preserves legacy behavior.
firstFolder Always use workspaceFolders[0]. Deterministic — independent of which file is focused.

The default preserves today's behavior exactly, so this is a non-breaking, opt-in change.

Motivation

The historic active-editor heuristic is convenient but non-deterministic: switching the focused file between roots silently changes which project config is picked up, and it can disagree with the marketplace installers (which always target workspaceFolders[0]). firstFolder gives a stable root for CI/automation and multi-root setups where only one folder is the real project.

Changes

Port notes

  • Settings namespace adapted from the fork's roo-cline.* to Zoo-Code's zoo-code.*.
  • The test reads the shared vscode mock via resolve.alias (mutation-based) to match Zoo-Code's src/vitest.config.ts.

Testing

cd src && npx vitest run utils/__tests__/path.spec.ts30 passed. Both modified JSON files validated as parseable. Pre-commit lint hooks passed.

Summary by CodeRabbit

  • New Features

    • Added a new setting, "Workspace Root Resolution" with options "activeEditor" (default) and "firstFolder" to control which workspace folder is used in multi-root workspaces.
  • Documentation

    • Added spec describing the new setting, behavior matrix for multi-root/no-workspace scenarios, and fallout/limitations.
  • Localization

    • Added translated descriptions for the new setting across many locales.
  • Tests

    • Expanded tests to cover both resolution modes and configuration-read fallbacks.

Introduces a new zoo-code.workspace.rootResolution VS Code setting with two strategies:

- activeEditor (default): legacy behavior - prefer the workspace folder containing the active editor, fall back to workspaceFolders[0].

- firstFolder: deterministic - always use workspaceFolders[0], independent of the focused file.

Updates getWorkspacePath() and getWorkspacePathForContext() in src/utils/path.ts to honor the setting, registers it in src/package.json with localized strings in src/package.nls.json, expands src/utils/__tests__/path.spec.ts with focused unit tests for both strategies, and adds a design doc at docs/design/workspace-root-resolution.md.

Ported from simurg79/Roo-Code commit d89c1ff (settings namespace adapted roo-cline -> zoo-code).
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2dc2aa22-199c-4d17-9609-b2cd738e38d8

📥 Commits

Reviewing files that changed from the base of the PR and between b8f5058 and 93543b8.

📒 Files selected for processing (17)
  • src/package.nls.ca.json
  • src/package.nls.de.json
  • src/package.nls.es.json
  • src/package.nls.fr.json
  • src/package.nls.hi.json
  • src/package.nls.id.json
  • src/package.nls.it.json
  • src/package.nls.ja.json
  • src/package.nls.ko.json
  • src/package.nls.nl.json
  • src/package.nls.pl.json
  • src/package.nls.pt-BR.json
  • src/package.nls.ru.json
  • src/package.nls.tr.json
  • src/package.nls.vi.json
  • src/package.nls.zh-CN.json
  • src/package.nls.zh-TW.json
✅ Files skipped from review due to trivial changes (7)
  • src/package.nls.ca.json
  • src/package.nls.pt-BR.json
  • src/package.nls.id.json
  • src/package.nls.vi.json
  • src/package.nls.ko.json
  • src/package.nls.zh-TW.json
  • src/package.nls.es.json

📝 Walkthrough

Walkthrough

Adds a zoo-code.workspace.rootResolution setting (values: activeEditor, firstFolder) and updates documentation, VS Code configuration + i18n, resolver logic (safe config read, deterministic first-folder mode, short-circuiting in context lookup), and tests covering both strategies and edge cases.

Changes

Workspace Root Resolution Feature

Layer / File(s) Summary
Design specification
docs/design/workspace-root-resolution.md
Design document specifying the new zoo-code.workspace.rootResolution setting, its two modes, exception-safe config read, behavior matrix, non-effects, usage guidance, and test coverage expectations.
Configuration schema and localization
src/package.json, src/package.nls.json, src/package.nls.* (locale files)
Adds zoo-code.workspace.rootResolution to extension configuration (activeEditor default, firstFolder option) and inserts localized description strings in the main NLS and all locale files.
Workspace resolution implementation
src/utils/path.ts
Exports WorkspaceRootResolution type; implements getRootResolutionStrategy() with try/catch fallback; updates getWorkspacePath() to use firstFolder deterministically or prefer the active editor's folder; getWorkspacePathForContext() short-circuits in firstFolder mode.
Test coverage and helpers
src/utils/__tests__/path.spec.ts
Refactors VS Code mock wiring to shared import; adds setRootResolution and withWorkspaceMock helpers; adds tests for both modes, fallback scenarios, config read exceptions, and verifies getWorkspaceFolder call patterns.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • navedmerchant
  • hannesrudolph
  • proyectoauraorg
  • taltas
  • edelauna

Poem

🐰 I hopped through folders, one and many,
Choosing roots when paths grew uncanny.
Active editor or first one true,
Now Zoo knows which root to use.
A small hop, a tidy rule—peace for the devs and me.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description includes a summary of changes, motivation, detailed file changes, port notes, and testing results. However, it does not include the required GitHub issue link in the 'Related GitHub Issue' section or other template sections like Pre-Submission Checklist. Add the required 'Closes: #<issue_number>' reference to link this PR to its GitHub issue, and consider including the Pre-Submission Checklist to confirm code review and testing were completed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and specifically describes the main feature being added: a new rootResolution setting for handling workspace root detection in multi-root VS Code workspaces.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Adds the three settings.workspace.rootResolution.* keys to all 17 non-English package.nls locale files to fix the check-translations CI check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant